<?php
/**
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * @author Eddie Drapkin <eddie@frameweld.com> 
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt
 * @package Solphr
 * @subpackage Query
 * @version 0.1-pre
 */

/**
 * Class is used to represent a simple integer, most likely) range for Solr.
 * 
 * @author Eddie Drapkin
 * @copyright Copyright 2009, Frameweld, LLC. (http://www.frameweld.com)
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt
 * @package Solphr
 * @subpackage Query
 */

class Solphr_Query_DateRange implements Solphr_Query_Interface {
	private $start;
	private $end;
	private $field;
	
	/**
	 * Class constructor
	 * @param mixed $start The start date, leave null for blank.
	 * @param mixed $end The end date, leave null for blank.
	 */
	public function __construct($start = null, $end = null, $fieldName = null) {
		$this->start = isset($start) ? $start : '*';
		$this->end = isset($end) ? $end : '*';
		$this->field = isset($field) ? $field : false;
	}
	
	/**
	 * @see Solphr/Query/Solphr_Query#__toString()
	 */
	public function __toString() {
		if(empty($this->field)) {
			return "[{$this->start} TO {$this->end}]";
		} else {
			return "{$this->field}:[{$this->start} TO {$this->end}]";
		}
	}
}